package com.hzvdvmc.autosale.socket;

import android.text.TextUtils;

import com.hzvdvmc.autosale.sale.bean.PaySuccessBean;
import com.hzvdvmc.autosale.util.LogUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by william on 2018/1/2.
 */

public class TempDataHelper {

    public static int OUTSTATE_UNOUT = 0;//未出货
    public static int OUTSTATE_OUTING = 1;//正在出货
    public static int OUTSTATE_SUCCESS = 2;//出货成功

    public static final int MAX_COUNT = 20;
    public static List<PaySuccessBean> tempList = new ArrayList<>();

    public static List<PaySuccessBean> getTempList() {
        return tempList;
    }


    public static void clear(){
        tempList.clear();
    }

    public static void setOutStateByOrderNO(String orderNO, int outState) {
        for (int i = 0; i < tempList.size(); i++) {
            if (tempList.get(i).getOrderNO().equals(orderNO)) {
                tempList.get(i).setOutState(outState);
                LogUtil.i("匹配状态已变更。。。");
                break;
            }
        }
    }

    public static String getTuneNObyOrderNO(String orderNO) {
        String tuneNO = "";
        for (int i = 0; i < tempList.size(); i++) {
            if (tempList.get(i).getOrderNO().equals(orderNO)) {
                tuneNO = tempList.get(i).getTuneNO();
                break;
            }
        }
        return tuneNO;
    }

    /**
     * 获取该订单的出货状态
     *
     * @param orderNO
     * @return
     */
    public static int getOutState(String orderNO) {
        if (TextUtils.isEmpty(orderNO)) {
            return -1;
        }
        int outWare = OUTSTATE_UNOUT;
        for (int i = 0; i < tempList.size(); i++) {
            if (tempList.get(i).getOrderNO().equals(orderNO)) {
                outWare = tempList.get(i).getOutState();
                break;
            }
        }
        return outWare;
    }

    /**
     * 该笔订单是否已缓存
     *
     * @param orderNO
     * @return
     */
    public static boolean isChache(String orderNO) {
        boolean isCache = false;
        for (int i = 0; i < tempList.size(); i++) {
            if (tempList.get(i).getOrderNO().equals(orderNO)) {
                isCache = true;
                break;
            }
        }
        return isCache;
    }

}
